<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>单元行上鼠标悬停提示</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .demo {
            width: 350px;
            margin: 50px auto;
            text-align: left;
            padding: 0;
        }

        .list {
            color: #2a6496;
        }

        .list li {
            position: relative;
            width: 320px;
            list-style: decimal inside;
            line-height: 35px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .list a {
            font-size: 18px;
        }

        .tip {
            position: absolute;
            left: 0;
            display: none;
            color: #fff;
            background: rgba(0, 0, 0, 0.6);
            line-height: 25px;
            font-size: 12px;
            padding: 2px 5px;
            border-radius: 5px;
            z-index: 1
        }

        .ellipsis {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
    <link rel="stylesheet" href="./reset.css" type="text/css">
</head>
<body>
<div id="div" class="demo">
    <ol class="list cc_cursor">
        <li><a href="#">铁路部门：火车票丢失需“先补买再退款”</a></li>
        <li><a href="#">新修订新疆宗教事务条例施行 禁止宣扬极端思想</a></li>
        <li><a href="#">长征火箭从天而降瞬间被拍下 民众围观(图)</a></li>
        <li><a href="#">呼格父母:今后不再上访 打算先给儿子买个好墓地</a></li>
        <li><a href="#">中国驻印尼使馆:印尼未对持普通护照中方人员免签</a></li>
        <li><a href="#">陕西圈养大熊猫发生犬瘟热 一8岁大熊猫死亡</a></li>
    </ol>
</div>
<div class="tip">新修订新疆宗教事务条例施行 禁止宣扬极端思想</div>
<script>
    let oOl = document.querySelector('.list');
    let oTip = document.querySelector('.tip');
    let oLi = oOl.getElementsByTagName('li');
    for (let i = 0; i < oLi.length; i++) {
        oLi[i].onmouseover = function () {
            oTip.innerHTML = oLi[i].innerText;
        }
        oLi[i].onmousemove = function (e) {
            let clientX = e.clientX || e.pageX
            let clientY = e.clientY || e.pageY
            oTip.style.cssText = `left:${clientX + 20}px;
            top:${clientY + 20}px;display:block;`
        }
        oLi[i].onmouseout = function () {
            oTip.style.cssText = `display:none;`
        }
    }
</script>
</body>
</html>
